home *** CD-ROM | disk | FTP | other *** search
/ The Sunday Times: The Month 2004 August / The Sunday Times - The Month 2004-08.iso / pc / engine / modules / thumbs_bck.swf / scripts / frame_1 / DoAction.as
Encoding:
Text File  |  2004-06-24  |  5.2 KB  |  207 lines

  1. function loadImage(mc, node, extrapath)
  2. {
  3.    var _loc3_ = extrapath;
  4.    if(_loc3_ == null)
  5.    {
  6.       _loc3_ = "";
  7.    }
  8.    var strDefaultPath = Tardis.ASSETS_FOLDER + "images/" + Tardis.ActiveSection.id + "/";
  9.    var _loc1_ = node.firstChild.nodeValue;
  10.    var _loc2_ = node.attributes.path;
  11.    if(_loc2_ != null)
  12.    {
  13.       _loc1_ = _loc2_ + _loc1_;
  14.    }
  15.    else
  16.    {
  17.       _loc1_ = strDefaultPath + _loc3_ + _loc1_;
  18.    }
  19.    if(strPathPrefix == null)
  20.    {
  21.       strPathPrefix = "";
  22.    }
  23.    mc.loadMovie(strPathPrefix + _loc1_);
  24. }
  25. function addLink(mc)
  26. {
  27.    Links[mc.link] = mc;
  28. }
  29. function getMCfromLink(Item)
  30. {
  31.    var _loc1_ = Item;
  32.    if(Links[_loc1_] == null)
  33.    {
  34.       var _loc2_ = [];
  35.       while(_loc1_ != sideMenu.ItemHome)
  36.       {
  37.          _loc2_.unshift(_loc1_._name.split("_").pop());
  38.          _loc1_ = _loc1_._parent._parent;
  39.       }
  40.       var _loc3_ = _loc2_.join("/");
  41.       Links[_loc1_] = Links[_loc3_];
  42.    }
  43.    return Links[_loc1_];
  44. }
  45. function removeLinkListener()
  46. {
  47.    Tardis.sideMenu.EB.removeListener(this);
  48. }
  49. function txtOver(mc)
  50. {
  51.    var _loc1_ = mc;
  52.    _loc1_.gotoAndStop("over");
  53.    temp.text = "num = " + _loc1_.num;
  54.    _parent.preview.doOver(_loc1_.num);
  55.    Tardis.sideMenu.doOver(_loc1_.link);
  56. }
  57. function txtOut(mc)
  58. {
  59.    var _loc1_ = mc;
  60.    _loc1_.gotoAndStop("off");
  61.    _parent.preview.doOut(_loc1_.num);
  62.    Tardis.sideMenu.doOut(_loc1_.link);
  63. }
  64. function txtUp(mc)
  65. {
  66.    Tardis.sideMenu.doUp(mc.link);
  67. }
  68. function init()
  69. {
  70.    widthArray = new Array([350,375,"portrait"],[548,243,"landscape"],[266,375,"portrait"],[350,266,"landscape"],[350,386,"landscape"]);
  71.    layoutID = nodeData.attributes.layout;
  72.    initx = 10;
  73.    inity = 10;
  74.    var _loc2_ = Tardis.ActiveSection.id;
  75.    var _loc1_ = Tardis.Colors;
  76.    var strColor = _loc1_.getString(_loc2_);
  77.    SECTION_COLOR = _loc1_.getHex(_loc2_);
  78.    DEFAULT_COLOR = _loc1_.getHex("default");
  79.    THUMB_PATH = nodeData.attributes.thumbpath;
  80.    bnlHasPreview = nodeData.attributes.haspreview;
  81.    onComplete();
  82.    bespokeInit();
  83.    initLayout();
  84. }
  85. function setClipPositions()
  86. {
  87.    var _loc1_ = Math.ceil(nodeData.childNodes.length * 0.5);
  88.    xmargin = (widthArray[layoutID][0] - (_loc1_ - 1) * 10) / _loc1_;
  89.    ymargin = (widthArray[layoutID][1] - (_loc1_ - 1) * 10) / _loc1_;
  90. }
  91. function initLayout()
  92. {
  93.    this.createEmptyMovieClip("mc_holder",depth++);
  94.    mc_holder._x = 0;
  95.    mc_holder._y = 10;
  96.    x = 0;
  97.    setClipPositions();
  98.    this.onEnterFrame = function()
  99.    {
  100.       if(x < nodeData.childNodes.length)
  101.       {
  102.          mc_holder.attachMovie("thumb_mc","mc_text_" + x,depth++);
  103.          var _loc2_ = Math.ceil(nodeData.childNodes.length * 0.5);
  104.          if(widthArray[layoutID][2] == "landscape")
  105.          {
  106.             if(x < _loc2_)
  107.             {
  108.                var xPos = x * xmargin + x * 10 + initx;
  109.             }
  110.             else
  111.             {
  112.                adjx = x - _loc2_;
  113.                var xPos = adjx * xmargin + adjx * 10 + initx;
  114.             }
  115.             if(x < nodeData.childNodes.length * 0.5)
  116.             {
  117.                var _loc3_ = 0;
  118.             }
  119.             else
  120.             {
  121.                _loc3_ = widthArray[layoutID][1] * 0.5;
  122.             }
  123.          }
  124.          else
  125.          {
  126.             var _loc1_ = Math.floor(x * 0.5);
  127.             if(x % 2 == 1)
  128.             {
  129.                var xPos = widthArray[layoutID][0] * 0.5 + initx;
  130.             }
  131.             else
  132.             {
  133.                var xPos = 0 + initx;
  134.             }
  135.             _loc3_ = _loc1_ * ymargin + _loc1_ * 10;
  136.          }
  137.          mc_holder["mc_text_" + x]._x = xPos;
  138.          mc_holder["mc_text_" + x]._y = _loc3_;
  139.          x++;
  140.       }
  141.       else
  142.       {
  143.          delete this.onEnterFrame;
  144.       }
  145.    };
  146. }
  147. function doOver(num)
  148. {
  149.    mc_holder["mc_text_" + num].gotoAndStop("over");
  150. }
  151. function doOut(num)
  152. {
  153.    mc_holder["mc_text_" + num].gotoAndStop("off");
  154. }
  155. function positionElements(mc, img)
  156. {
  157.    var _loc1_ = mc;
  158.    var _loc2_ = img;
  159.    _loc1_.titleFF._width = _loc2_._width;
  160.    _loc1_.titleFF._y = _loc2_._height;
  161.    _loc1_.link = _loc1_.nd.attributes.link;
  162.    _loc1_.titleFF.htmlText = _loc1_.nd.byName("thumbtitle").getText();
  163.    if(_loc1_._currentframe < 15)
  164.    {
  165.       _loc1_.titleFF.textColor = DEFAULT_COLOR;
  166.    }
  167.    else
  168.    {
  169.       _loc1_.titleFF.textColor = SECTION_COLOR;
  170.    }
  171.    _loc1_.activeBtn._width = _loc2_._width + 10;
  172.    _loc1_.activeBtn._height = _loc2_._height + _loc1_.titleFF._height;
  173.    _loc1_._visible = true;
  174. }
  175. function clipInit(clip)
  176. {
  177.    num = clip._name.split("_")[2];
  178.    clip.num = num;
  179.    clip.nd = nodeData.childNodes[num];
  180.    imgToCheck = eval(clip.mc_img);
  181.    clip.intervalID = setInterval(checkLoad,500,clip,imgToCheck);
  182. }
  183. function checkLoad(mc, img)
  184. {
  185.    var _loc1_ = mc;
  186.    if(img._height > 0)
  187.    {
  188.       if(!_loc1_.positioned)
  189.       {
  190.          _loc1_.positioned = true;
  191.          positionElements(_loc1_,img);
  192.          clearInterval(_loc1_.intervalID);
  193.       }
  194.    }
  195. }
  196. Links = {};
  197. Tardis.sideMenu.EB.addListener(this);
  198. stop();
  199. onReady();
  200. this.onUnload = function()
  201. {
  202.    bespokeUnload();
  203.    removeLinkListener();
  204.    clearInterval(intervalID);
  205.    this.onUnload = null;
  206. };
  207.